<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>管理员登录</title>
    <script type="text/javascript" src="./js/vue.js"></script>
    <script type="text/javascript" src="./js/axios.js"></script>
</head>
<body>
<h2>管理员登录</h2>
已登录？<a href="admin/admin.html">进入管理员界面</a>
<hr>
<form id="app">
    <label>用户名</label><input v-model="username" type="text"><br>
    <label>密码</label><input v-model="password" type="password"><br>
    <input v-on:click="login" type="button" value="登录"><br>
</form>
<script>
    var app = new Vue({
        el: "#app",
        data: {
            username: null,
            password: null
        },
        methods: {
            login: function () {
                var that = this;
                axios({
                    method: "post",
                    url: "http://localhost:8080/admin/login",
                    params: {
                        username: this.username,
                        password: this.password
                    },
                }).then(function (response) {
                    if (response.data.flag) {
                        window.location.href = "http://localhost:8080/admin/admin.html";
                    }
                }, function (err) {
                    console.log(err);
                });
            }
        }
    });
</script>
</body>
</html>